package z.lib.base;

import java.util.Map;

import org.com.app.knock.KnockApplication;

import z.lib.base.callback.RestClient.RequestMethod;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.util.Log;

public class BaseUtils {

	public static class API {
		public static final String BASESERVERROOT = "http://knock.codelovers.vn/";
		public static final String BASESERVER = BASESERVERROOT + "api/";
		public static final String API_DATA = "user/data";//OK
		public static final String API_USER_REGISTER = "user/register";
		public static final String API_USER_LOGIN = "user/login";//OK
		public static final String API_USER_GETLOGIN = "user/get_login";//_user_id, _token
		public static final String API_USER_LOGOUT = "user/logout";//_user_id, _token
		public static final String API_USER_DEVICE = "user/set_devicetoken";//OK _user_id, _token, platform, devicetoken
		public static final String API_USER_SAVE ="user/save";
		public static final String API_FRIEND ="friend/";//_user_id, _token OK
		public static final String API_FRIEND_SEARCH = "friend/search";//OK
		public static final String API_FRIEND_ADD = "friend/add";//friend_id  OK
		public static final String API_FRIEND_REMOVE = "friend/remove";//friend_id OK
		public static final String API_FRIEND_BLOCKLIST = "friend/blocklist";//OK
		public static final String API_FRIEND_BLOCK = "friend/block";//friend_id OK
		public static final String API_FRIEND_UNBLOCK = "friend/unblock";//friend_id OK
		public static final String API_MESSAGE_SEND = "message/send";//last_message_created
		public static final String API_MESSAGE_RECEIVED = "message/received";
		public static final String API_MESSAGE_ADD = "message/add";//friend_id, icon_id OK
		

	}

	public static final class KEY {
		public static final String KEY_SCREEN = "KEY_SCREEN";
		public static final String is_success = "code";
		public static final String err_msg = "message";
		public static final String REMEMBERPASSWORD = "req[param][remember]";
	}

	public enum SCREEN {
		LOGIN, MAIL_BOX, FAQ, DOWNLOAD, CONTACT, NEWS, ABOUT_SPMC, HOME, DEFAULT, PROFILE
	}

	public final static class VALUE {

		public static final String STATUS_API_SUCCESS = "OK";
		public static final String STATUS_REMEMBER_SUCCESS = "1";
		public static final String STATUS_API_FAIL = "0";

	};

	public static void execute(Context context, final RequestMethod method, final String api, final Map<String, String> params, final BaseServiceCallBack cheerzServiceCallBack) {
		((KnockApplication) context.getApplicationContext()).execute(method, api, params, cheerzServiceCallBack);
	}

	public static void showDialog(Context activity, String message) {
		Builder builder = new Builder(activity);
		builder.setMessage(message);
		builder.show();
	}

	public static void playMedia(Context context,int mediaid){
		try {
			MediaPlayer mediaplayer = new MediaPlayer();
			mediaplayer = MediaPlayer.create(context, mediaid);        
			if(mediaplayer == null) {            
			    Log.v("media err", "Create() on MediaPlayer failed.");       
			} else {
			    mediaplayer.setOnCompletionListener(new OnCompletionListener() {

			    @Override
			      public void onCompletion(MediaPlayer mediaplayer) {
			          mediaplayer.stop();
			          mediaplayer.release();
			      }
			    });
			    mediaplayer.setVolume(0.9f, 0.9f);
			    mediaplayer.start();

			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
